home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
comm
/
tlx_sq15.zip
/
GRABMAIL.SLT
< prev
next >
Wrap
Text File
|
1991-02-06
|
16KB
|
466 lines
//-----------------------------------------------------------
// GrabMail.SL? Telix script to fetch mail from a PCBoard BBS.
//
// This script is normally called from the script PCBOARD.SLC.
//
// Please look at the comments through the whole file, and modify to
// suit your needs, BEFORE you use it. Then recompile with CS GrabMail.
// Note: Lines commented out with //!! are not used in this script,
// but in other, related ones. Please don't delete them; they may
// become useful later.
//-----------------------------------------------------------
str command [10]="Command:" // Command prompt.
,input [80] // One input line.
,f0 [14] // Filename for download.
,runstr [80]="" // Run string for DSZ.
,maildir [64] // Mail directory or download directory.
,myprot [2] // My protocol
,hisprot [2] // PCB's protocol
// For the Global storage:
,global []="GLOBAL" // Global script.
,bbstype []="BTYPE" // BBS type.
,short []="SHORT" // Short BBS name.
,Cprot []="CPROT" // Current protocol.
,Hprot []="HPROT" // "His" protocol.
,version []="PCBVER" // PCB version
,mdir []="MDIR" // Mail directory.
,prompt []="PROMPT" // Current command prompt.
,dsz []="DSZ" // DSZ parameters.
;
int tol = 600 // No activity for 1 minute
,tmark // makes script time out.
,stat // For tracking.
,PCBver // PCBoard version.
,MORE // More messages
,pcb, mbbs, rbbs, opus, fido, crcs // different kinds of systems
,protocol
,usedsz // = 1 if using DSZ.
,file
;
//-----------------------------------------------------------
// GrabMail script is entered here.
//-----------------------------------------------------------
main()
{
int i;
// This script is assumed to be called ONLY after logon
// to perform routine tasks. This is done from the PCBoard
// script, and we MUST be in the "ProDoor" door.
// The TELIX main directory must be the current one.
// Therefore, system and online checks are simply skipped.
entry(); // Updates status bar.
newdir (_telix_dir); // Must be in TELIX main directory!
read (prompt,command); // Get command prompt.
read (version,input);
PCBver = stoi (input); // Get PCBoard version.
read (cprot,myprot); // Get protocol.
protocol = subchr (myprot,0); // Must be INT.
read (hprot,hisprot);
// Check which BBS system.
read (bbstype,input);
mbbs = pcb = rbbs = opus = fido = crcs = 0;
if (input == "MBBS") mbbs = 1;
else if (input == "PCB" ) pcb = 1;
else if (input == "RBBS") rbbs = 1;
else if (input == "OPUS") opus = 1;
else if (input == "FIDO") fido = 1;
else if (input == "CRCS") crcs = 1;
else
{ wrongBBS(); // Doesn't match script!
return (-1);
}
// ZIPM or GRAB messages.
//-----------------------------------------------------------
if (read (dsz,runstr) > 0 // Are we using DSZ?
&& protocol == 'Z')
{ strcat (runstr," rz -m"); // Add parameters.
usedsz = 1;
}
else // No.
usedsz = 0;
MORE = 1;
while (MORE)
{ f0 = ""; // No name yet.
if (mbbs)
grab();
else if (pcb)
{ if (PCBver < 145)
zipm();
else
raz(); // PCBoard 14.5 and later
}
}
return (0);
}
//-----------------------------------------------------------
// This routine GRABS messages from MBBS.
//-----------------------------------------------------------
grab()
{
str filename[]="ilename: "; // Look for this text.
int t1, t2, t3, mm;
MORE = 0; // Donit.
t1 = track ("command!", 0); // Define new tracks.
t2 = track ("Dumping ", 0);
t3 = track ("on disk!", 0); // Not enough space for GRAB.
mm = track ("More Messages", 0); // More messages.
file = track (filename, 0); // Filename comes here.
tmark = timer_start (tol); // Give me a minute.
cputs ("grab^M"); // Send a GRAB command.
while ((stat=trig()) > 0) // answer any questions
{ if (stat == t1) // Illegal command (line error!)
cputs ("grab^M"); // Send a new command.
else if (stat == t2) // "Dumping..."
; // Something's happening...
else if (stat == mm) // More messages next time.
MORE = 1;
else if (stat == t3) // Disc is full - Can't GRAB.
return (0); // Return to user.
else if (stat == file) // Filename expected?
break;
}
get_file(filename); // Get the file.
}
//-----------------------------------------------------------
// This routine fetches messages from PCBoard rev. >= 14.5.
//-----------------------------------------------------------
raz()
{
str filename[]="elected: "; // Look for this text.
int mm // More messages.
,messages // Messages to fetch if == 1.
,co // Command
,dot // More coming....
,ccm // Compressing captured mail
,ec1, ec2 // ENTER to continue
;
MORE = 0; // Donit.
messages = -1; // Command not sent.
tol = 1200;
do
{ cputs ("t "); // Set protocol. Not really necessary
cputs (hisprot); // every time, but we can't know
cputs ("^M"); // when it is.
waitfor (command,3);
cputs ("r a z^M"); // Send READ ALL, then ZIP.
co = track (command,0); // Back to command.
ec1 = track (")=continue?",0); // Press ENTER.
ec2 = track ("o download?",0); // Press ENTER.
ccm = track ("ressing capture",0); // Compressing captured mail.
mm = track (" limit reached)",0); // Max. limit reached.
dot = track ("Scan",0); // Signals that it's working.
file= track (filename,0); // Filename comes now.
tmark = timer_start (tol); // Set time-out.
while ((stat=trig()) > 0) // answer any questions.
{ if (stat == co) // Command?
{ if (messages==1) // Messages?
goto fail; // Failure!!!
else if (messages >= 0) // No mail or receive
break; // ready.
else
goto fail; // Try again.
}
else if (stat==dot // More coming?
&& messages < 0)
messages = 0; // Message command received.
else if (stat == ccm) // Compressing mail?
messages = 1; // Messages to fetch.
else if (stat==ec1 || stat==ec2) // ENTER to continue???
cputs ("^M"); // Continue.
else if (stat == mm) // More messages?
MORE = 1;
else if (stat == file) // Filename expected?
{ messages = 1;
break; // Go get the mail file.
}
}
if (messages > 0)
get_file (filename); // Get the mail file.
break;
fail: // Repeat from here if fail.
release();